package com.adams.sys.icon.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.adams.access.db.bean.Icon;
import com.adams.encache.mechanism.CacheUtil;
import com.adams.sys.icon.dao.IconDao;
import com.adams.sys.icon.service.IconService;
import com.adams.utils.Page;

/**
 * 
 * 
 * File Name : IconServiceImpl.java
 * 
 * @Description : 图标管理服务类，提供对图标的增、删、改查功能
 * @author 902990封文进
 */
@Service("iconService")
@Transactional
public class IconServiceImpl implements IconService
{

	@Autowired
	private IconDao iconDao;

	public void setIconDao(IconDao iconDao)
	{
		this.iconDao = iconDao;
	}

	/**
	 * 
	 * Description : 创建图标
	 * 
	 * @param icon
	 * 
	 */
	@Transactional(rollbackFor = java.lang.Exception.class)
	public void createIcon(Icon icon)
	{
		icon.setVersion(1);
		iconDao.save(icon);
		CacheUtil.clearCacheByClass(Icon.class);
	}

	/**
	 * 
	 * Description : 更新图标
	 * 
	 * @param icon
	 * 
	 */
	@Transactional(rollbackFor = java.lang.Exception.class)
	public void updateIcon(Icon icon)
	{
		iconDao.update(icon);
		CacheUtil.clearCacheByClass(Icon.class);
	}

	/**
	 * 
	 * Description : 删除图标
	 * 
	 * @param icon
	 * 
	 */
	@Transactional(rollbackFor = java.lang.Exception.class)
	public void deleteIcon(Icon icon)
	{
		iconDao.delete(icon);
		CacheUtil.clearCacheByClass(Icon.class);
	}

	/**
	 * 
	 * Description : 根据编号查询图标
	 * 
	 * @param id
	 * @return Icon
	 * 
	 */
	@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
	public Icon queryById(Long id)
	{
		return iconDao.get(id);
	}

	/**
	 * 
	 * Description : 根据分页查询图标
	 * 
	 * @param page
	 * @return Page<Icon>
	 * 
	 */
	@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
	public Page<Icon> queryAllByPage(Page<Icon> page)
	{
		return iconDao.queryAllByPage(page);
	}

}
